tabclick();
console.log(GetQueryString("money"));
console.log(GetQueryString("kind"));
//			顶部选项
var headBlock = document.getElementsByClassName('head_block');
//			金额,贷款类型,排序弹出
var headBlockDetail = document.getElementsByClassName('head_block_detail');
//			箭头
var xficon = document.getElementsByClassName("xficon");
var dbMoney = document.getElementsByClassName("db_money");
var dbKind = document.getElementsByClassName("db_kind");
var dbOrder = document.getElementsByClassName("db_order");
console.log(GetQueryString("money"))
var money;
var kind;
var order=0;
var str;
var count = 0;
if(GetQueryString("money")==""){
	money=0;
}else{
	money=GetQueryString("money");
}
if(GetQueryString("kind")==""){
	kind=0;
}else{
	kind=GetQueryString("kind");
}

if(GetQueryString("money1") !== "") {
	document.getElementById("which_money").innerHTML = GetQueryString("money1");
}
if(GetQueryString("kind1") !== "") {
	document.getElementById("whiich_kind").innerHTML = GetQueryString("kind1");

}
for(var i = 0; i < 3; i++) {
	headBlock[i].index = i;
	headBlock[i].addEventListener('tap', function() {

		if(headBlockDetail[this.index].className == 'head_block_detail active') {
			document.getElementsByClassName('choose')[0].style.display = 'none';
			headBlockDetail[this.index].className = 'head_block_detail';
			xficon[this.index].className = 'xficon mui-icon mui-icon-arrowdown';
			//						alert(1);
			return;
		} else {
			for(var j = 0; j < 3; j++) {
				headBlockDetail[j].className = 'head_block_detail';
				xficon[j].className = 'xficon mui-icon mui-icon-arrowdown';
			}
			document.getElementsByClassName('choose')[0].style.display = 'block';
			headBlockDetail[this.index].className = 'head_block_detail active';
			xficon[this.index].className = 'xficon mui-icon mui-icon-arrowup';
		}

	})
}
//          顶部金额,贷款类型,排序点击事件
function Check(dbOrder, nn, cc) {
	for(var i = 0; i < dbOrder.length; i++) {
		dbOrder[i].index = i;
		dbOrder[i].addEventListener('tap', function() {
			document.getElementById('which_order').innerHTML = this.innerHTML;
			for(var i = 0; i < dbOrder.length; i++) {
				dbOrder[i].style.color = 'rgb(121,121,121)';
				dbOrder[i].style.border = '1px solid rgb(121,121,121)';
			}
			this.style.color = '#f26100';
			this.style.border = '1px solid #f26100';
			order = this.index;
			count=0;
			document.getElementById("dae").innerHTML='';
			serchType();
			console.log(order);
			document.getElementsByClassName('choose')[0].style.display = 'none';
			for(var j = 0; j < 3; j++) {
				headBlockDetail[j].className = 'head_block_detail';
				xficon[j].className = 'xficon mui-icon mui-icon-arrowdown';
			}
		})
	}

}

Check(dbOrder, 'which_order', order);
//          $.ajax({
//					type: 'get',
//					url: httpAdress + '/api/borrow/amount/getamount',
//					contentType: "application/json; charset=utf-8",
//					dataType: 'jsonp',
//					jsonp: "callback",
//					jsonpCallback: "successCallback",
//					success: function(data) {
//						console.log(JSON.stringify(data))
//					},
//					error: function() {
//						mui.toast('加载失败，刷新一下');						
//					}
//				});
$.ajax({
	type: 'get',
	url: httpAdress + '/api/borrow/type/gettype',
	contentType: "application/json; charset=utf-8",
	dataType: 'jsonp',
	jsonp: "callback",
	jsonpCallback: "successCallback",
	success: function(data) {
		console.log(JSON.stringify(data));
		var mydata = data.data;
		var strkind;
		for(var i = 0; i < mydata.length; i++) {
			$('<div class="detail_block db_kind">' + mydata[i].name + '</div>').appendTo("#xfkind");
			document.getElementsByClassName("detail_block db_kind")[i].index = i;
			document.getElementsByClassName("detail_block db_kind")[i].addEventListener('tap', function() {
				document.getElementById('whiich_kind').innerHTML = this.innerHTML;
				for(var i = 0; i < dbKind.length; i++) {
					dbKind[i].style.color = 'rgb(121,121,121)';
					dbKind[i].style.border = '1px solid rgb(121,121,121)';
				}
				this.style.color = '#f26100';
				this.style.border = '1px solid #f26100';
				kind = mydata[this.index].id;
				console.log(kind);
				count=0;
				document.getElementById("dae").innerHTML='';
				serchType();
				document.getElementsByClassName('choose')[0].style.display = 'none';
				for(var j = 0; j < 3; j++) {
					headBlockDetail[j].className = 'head_block_detail';
					xficon[j].className = 'xficon mui-icon mui-icon-arrowdown';
				}
			})
		}
		$.ajax({
			type: 'get',
			url: httpAdress + '/api/borrow/amount/getamount',
			contentType: "application/json; charset=utf-8",
			dataType: 'jsonp',
			jsonp: "callback",
			jsonpCallback: "successCallback",
			success: function(data) {
				console.log(JSON.stringify(data));
				var mydata = data.data;
				for(var i = 0; i < mydata.length; i++) {
					$('<div class="detail_block db_money">' + mydata[i].money + '</div>').appendTo("#xfmoney");
					document.getElementsByClassName("detail_block db_money")[i].index = i;
					document.getElementsByClassName("detail_block db_money")[i].addEventListener('tap', function() {
						document.getElementById('which_money').innerHTML = this.innerHTML;
						for(var i = 0; i < dbMoney.length; i++) {
							document.getElementsByClassName("db_money")[i].style.color = 'rgb(121,121,121)';
							document.getElementsByClassName("db_money")[i].style.border = '1px solid rgb(121,121,121)';
						}
						this.style.color = '#f26100';
						this.style.border = '1px solid #f26100';
						money = mydata[this.index].id;
						count=0;
						document.getElementById("dae").innerHTML='';
						serchType();
						console.log(money);
						document.getElementsByClassName('choose')[0].style.display = 'none';
						for(var j = 0; j < 3; j++) {
							headBlockDetail[j].className = 'head_block_detail';
							xficon[j].className = 'xficon mui-icon mui-icon-arrowdown';
						}
					})
				}
			    serchType();
			},
			error: function() {
				mui.toast('加载失败，刷新一下');
			}
		});
	},
	error: function() {
		mui.toast('加载失败，刷新一下');
	}
});
//          serchType();
function serchType() {

	//	var dae = document.getElementById('dae');
	$.ajax({
		type: 'get',
		url: httpAdress + '/api/borrow/product/searchproduct',
		contentType: "application/json; charset=utf-8",
		dataType: 'jsonp',
		jsonp: "callback",
		jsonpCallback: "successCallback",
		data: {
			money: money,
			type: kind,
			order: order,
			first: count
		},
		success: function(data) {
			var mydata = data.data.data;
			console.log(JSON.stringify(data));
			console.log("金额:"+money+"类型:"+kind+"排序:"+order+"first:"+count);
			var str = '';
			document.getElementById("product_num").innerHTML = data.data.coun;
			for(var i = 0; i < mydata.length; i++) {

				var strstart1 = '';
				var strstart2 = '';
				var strstart3 = '';
				for(var a = 0; a < mydata[i].start; a++) {
					strstart1 += ' <img src="../../img/daikuan/img-star@3x.png"/>'
				}
				for(var b = 0; b < (5 - mydata[i].start); b++) {
					strstart2 += ' <img src="../../img/daikuan/img-star-half@3x.png"/>'
				}
				if(i<3) {
					strstart3 = '<img class="post" src="../../image/other/img_jian@2x.png"/>';
				}
				$('<li class=" mui-media listb">' +
					'<a class="dispaly-flex" href="'+'../../HTML/home/home_fast_detail.html?mproid=' + mydata[i].id +'&mdname=' + mydata[i].name +'">' +
					'<img class="item-img mui-media-object mui-pull-left" src="' + httpAdress + mydata[i].logo + '">' +
					'<div class="mui-media-body">' +
					'<div class="top">' +
					' <span class="mui-media-body-name">' + mydata[i].name + '</span>' +
					strstart1 + strstart2 +
					'</div>' +
					'<div class="block">' +
					'<span class="mation">下款人数</span><br />' +
					'<span class="num">' + mydata[i].count + '人</span>' +
					'</div>' +
					'<div class="block" style="text-align: center;">' +
					'<span class="mation">月利率</span><br />' +
					'<span class="lilv">' + mydata[i].rate + '</span>' +
					' </div>' +
					'<div class="block">' +
					'<span class="mation">放款时间</span><br />' +
					'<span class="num">' + mydata[i].loan_time + '</span>' +
					strstart3 +
					'</div></div> </a></li>').appendTo("#dae");
			}
			for(var i=3;i<document.getElementsByClassName("post").length;i++){
				document.getElementsByClassName("post")[i].style.display='none';
			}
			if(document.getElementsByClassName("post").length>3){
				document.getElementById("product_num_special").innerHTML = 3;
			}else{
				document.getElementById("product_num_special").innerHTML = document.getElementsByClassName("post").length;				
			}
//			document.getElementById("product_num_special").innerHTML ='3';			
           if(mydata.length<10){
           	     document.getElementById("addmore").style.display="block";
           	     document.getElementById("addmore1").innerHTML='没有更多了';
           }
		},
		error: function() {
			mui.toast('加载失败，刷新一下');
		}
	});
}

			
			document.getElementById('addmore').addEventListener('tap', function() {
				count = count + 10;
				serchType() ;
			})